<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/jquery.min.js"></script>

</head>

<body>
  <div class="yy hh">3
    <div class="bb hh">2
      <div class="erzi">1</div>
    </div>
  </div>
  <script>
    const $erzi = $('.erzi')
    //找到当前元素的上一级的父元素
    console.log($erzi.parent())
    //找到所有的父元素
    console.log($erzi.parents())
    //找到所有的有hehe类名的父元素
    console.log($erzi.parents('.hh'))
    //找到最近一级的有hehe类名的父元素
    console.log($erzi.closest('.hh'))

    const str = 'penggegezhendishuai'
    console.log(str.substring(0, 8))
  </script>
</body>

</html>